package com.fqcar.fqdf.util;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.fqcar.fqdf.DFApp;
import com.fqcar.fqdf.service.VolleySingleton;
import com.fqdf.framework.android.util.CheckLogicUtil;

/**
 * @author 张枭
 * @version V1.0
 * @date 2017/7/31
 * @desc
 */
public class SkipUtil {


    public static void stepNextWithCheckLogin(Context context, Class<? extends Activity> clazz, int forward, Bundle extras) {
        if (CheckLogicUtil.isEmpty(SharedPreferenceUtil.getStringSPAttrs(context, SharedPreferenceUtil.AttrInfo.USER_TOKEN, ""))) {
            stepToLogin(context, forward, null);
        } else {
            Intent intent = new Intent(context, clazz);
            if (null != extras) {
                intent.putExtras(extras);
            }
            context.startActivity(intent);
        }
    }

    /**
     * 检测跳到登录界面
     * @param context
     * @param forward
     * @param extras
     */
    public static void stepToLogin(Context context, int forward, Bundle extras) {
//        Intent intent = new Intent(context, LoginActivity.class);
//        intent.putExtra(Constants.LoginForward.KEY, forward);
//        if (null != extras) {
//            intent.putExtras(extras);
//        }
//        context.startActivity(intent);
    }

    /**
     * 退出app
     * @param context
     */
    public static void exitAPP(Context context) {
        VolleySingleton.getInstance().getRequestQueue().stop();
        ((DFApp) context.getApplicationContext()).stopLocation();
        ((Activity) context).finish();
        System.gc();
        System.exit(0);
    }
}
